<template>
    <div ref="pwd_dlg">
        <kv label="原密码">
            <el-input v-model="info2.pwd1" chk="{value.length}[4]"/>
        </kv>
        <kv label="新密码">
            <div>
                <el-input v-model="info2.pwd2"
                          chk=": if( value.length<8 ) return '长度不能小于8'; if( /^[\w\d]+$/.test(value) == false) return '只能包含数字和字母'; if( /\d/.test(value) == false) return '必须包含数字';if( /\w/.test(value) == false) return '必须包含字母'; "/>
                <div>长度必须大于8位，必须包含数字和字母</div>
            </div>
        </kv>
        <kv label="确认新密码">
            <el-input v-model="info2.pwd3" chk="{value.length}[4]"/>
        </kv>

        <div style="display: flex;justify-content: center;">
            <el-button size="mini" @click="changePwd();">确定</el-button>
        </div>
    </div>
</template>
<style scoped>
    >>> .kv .k {
        flex: 4 !important;
        min-width: auto !important;
    }
</style>
<script>
    /**
     * Created by CodeGenerator
     */
    export default {
        components: {},
        data() {
            return {
                pwd_dlg: false,
                info2: {}
            }
        },

        mounted() {
        },
        methods: {
            changePwd() {
                if (this.$refs.pwd_dlg.chk() == false) {
                    return;
                }
                if (this.info2.pwd2 != this.info2.pwd3) {
                    return jv.error("新密码与确认密码不一致")
                }
                this.$http.post("/site/user/changePassword/", this.info2).then(res => {
                    jv.info("设置成功");

                    this.$emit("change");
                })
            }
        }
    }
</script>
